#include <QtPlugin>

#include <QInputDialog>
#include <QVBoxLayout>
#include <QSpinBox>
#include <QWidget>
#include <QRadioButton>
#include <QList>
#include <QColor>
#include <QString>
#include <QFileDialog>
#include <QFile>
#include <QTextStream>
#include <QPushButton>
#include <QCheckBox>

#include <opencv/cv.h>
#include <opencv/highgui.h>

#include "QCVModuleInterface.h"
#include "QCVModuleHandlerInterface.h"

#include <iostream>

#include <qwt_plot_grid.h>
#include <qwt_plot_picker.h>
#include <qwt_plot_zoomer.h>
#include <qwt_plot_curve.h>
#include <qwt_plot.h>

#ifndef MODULE_PLOT_2D
#define MODULE_PLOT_2D

class ModulePlot2D:public QObject,QCVModuleInterface
{
  Q_OBJECT
	Q_INTERFACES(QCVModuleInterface)
	
	public:
		void init(QCVModuleHandlerInterface * parent);
		void free();

		cv::Mat & process();
		void setInput(int n,const cv::Mat & m);

		QWidget* widget();
		QString getName();
		int nbInputs();
		QString help(int id);
		bool setParams(QString params);
    QString getParams();

		QCVModuleInterface * clone();

	public slots:
		void s_save();
		void s_fitView();
		void s_process();

	private:  
    QWidget * win;
    QVBoxLayout * layout;
		QSpinBox * sb_delay;
		QRadioButton * rb_XY,* rb_Y;
		QCheckBox * cb_autoProcess;

		int nbCurves;		

		QwtPlot * plot;

		cv::Mat_<double> dataX,dataY;
		
		QList<QColor> colors;
		QwtPlotCurve * curves;

		QwtPlotZoomer * zoomer;
		QwtPlotPicker * picker;
		QwtPlotGrid * grid;

		QCVModuleHandlerInterface * parent;
		QPushButton * pb_save;
		QPushButton * pb_process;
		QPushButton * pb_fitView;
};

#endif
